<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models;

use App\Engine\BaseModel;
use Illuminate\Database\Eloquent\Model;

/**
 * Class HomeSet
 *
 * @property int $id
 * @property string|null $name
 * @property string|null $image
 * @property string|null $jump_url
 * @property int $sort
 * @property int $layout
 * @property int $show_title
 * @property int $w
 * @property int $h
 *
 * @package App\Models
 */
class HomeSet extends BaseModel
{
	protected $table = 'home_sets';
	public $timestamps = false;

	protected $casts = [
		'sort' => 'int',
		'layout' => 'int',
		'show_title' => 'int'
	];

	protected $fillable = [
		'name',
		'image',
		'sort',
		'layout',
		'show_title',
        'jump_url',
        'w',
        'h'
	];

    public $rule=[
        'name'=>'required',
        'image'=>'required',
        'sort'=>'required',
        'layout'=>'required',
        'show_title'=>'required',
    ];
    public $ruleMessage=[
        'name.required'=>"名称不能为空",
        'image.required'=>"请选择图片",
        'sort.required'=>"请输入序号",
        'layout.required'=>"布局类型不能为空",
        'show_title.required'=>"请选择状态",
    ];

    public $with=["article"];

    public function article()
    {
        return $this->belongsTo("App\Models\Article","jump_url","id");
    }
}
